﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <style type="text/css">
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>
    <link data-name="vs/editor/editor.main" href="~/lib/monaco-editor/min/vs/editor/editor.main.css" rel="stylesheet" />
</head>
<body>
    <button class="btn btn-info" type="button" onclick="lg()">保存</button>
    <div id="container" style="width:100%;height:700px;border:1px solid grey"></div>

    <script src="~/lib/jquery/jquery.min.js"></script>
    <script>var require = { paths: { 'vs': '/lib/monaco-editor/min/vs' } };</script>
    <script src="~/lib/monaco-editor/min/vs/loader.js" type="text/javascript"></script>
    <script src="~/lib/monaco-editor/min/vs/editor/editor.main.nls.js"></script>
    <script src="~/lib/monaco-editor/min/vs/editor/editor.main.nls.zh-cn.js"></script>
    <script src="~/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
    <script>
        var editor = monaco.editor;
        var curEditor;
        $.get("/admin/getfile", {path:"@(ViewBag.Path)"}, function (d) {
            if (d.ret == 0) {
            curEditor= editor.create(document.getElementById('container'), {
            value:d.data,
            language: 'javascript',
            //language: 'csharp'
            });
            } else {
                alert(d.ret);
            }
        });
        function lg() {
            var path = "@ViewBag.Path";
            console.log(path);
            //console.log(curEditor.getValue());
            $.post("/admin/postfile", { name: path, data: curEditor.getValue() }, function (d) {
                if (d.ret == 0) {
                    alert("提交成功");
                } else
                    alert(d.ex);
            })
            //editor.dispose();
        }
    </script>

</body>
</html>

